package me.shurufa.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.Bind;
import de.greenrobot.event.EventBus;
import me.shurufa.R;
import me.shurufa.utils.Constants;
import me.shurufa.utils.Global;
import me.shurufa.utils.Settings;

/**
 * 从我的ProfileFragment 点击设置弹出的页面
 *
 * @FileName: me.shurufa.activities.SettingsActivity.java
 * @author: kHRYSTAL
 * @email: 723526676@qq.com
 * @date: 2016-01-19 10:30
 */
public class SettingsActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.left_text)
    TextView leftText;
    @Bind(R.id.right_image)
    ImageView rightImage;
    @Bind(R.id.right_text)
    TextView rightText;
    @Bind(R.id.user_about_us_layout)
    LinearLayout userAboutUsLayout;
    @Bind(R.id.user_feedback_layout)
    LinearLayout userFeedbackLayout;
    @Bind(R.id.back_login)
    TextView backLogin;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        activity_layout_res = R.layout.activity_settings;
        super.onCreate(savedInstanceState);
        initUI();
    }

    private void initUI() {
        titleTextView.setText(getString(R.string.setting));
        userAboutUsLayout.setOnClickListener(this);
        userFeedbackLayout.setOnClickListener(this);
        backLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()){
            case R.id.user_about_us_layout:
                intent = new Intent(SettingsActivity.this,AboutUsActivity.class);
                startActivity(intent);
                break;
            case R.id.user_feedback_layout:
                intent = new Intent(SettingsActivity.this,FeedBackActivity.class);
                startActivity(intent);
                break;
            case R.id.back_login:
                EventBus.getDefault().post(new Intent(Constants.ACTION_USER_CHANGE));
                Settings.delUser(String.valueOf(Global.currentUser.uid));
                Global.currentUser = null;
                intent = new Intent(SettingsActivity.this,LoginActivity.class);
                startActivity(intent);
                finish();
                break;
        }
    }
}
